package com.example.job;// 用户服务1  用户服务2  用户服务3

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MyQuartzJobConfiguration {

    // 配置一个任务
    @Bean
    public JobDetail jobDetail1() {
        JobDetail jobDetail = JobBuilder.newJob(MyQuartzJob.class)
                .withIdentity("job1", "group1")
                .storeDurably()
                .build();
        return jobDetail;
    }


   // 配置一个 任务-调度器
    @Bean
    public Trigger trigger2() {
        Trigger trigger = TriggerBuilder.newTrigger()
                .forJob(jobDetail1())
                .withIdentity("trigger1", "group1")
                .startNow()
                 // 每个月的3号凌晨1点开始，每隔3秒执行一次
                .withSchedule(CronScheduleBuilder.cronSchedule("0/3 * 1 3 * ?"))
                .build();
        return trigger;
    }

}